<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class YAML::DBM - yaml: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">DBM
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-i-5B-5D">#[]</a>
    <li ><a href="#method-i-5B-5D-3D">#[]=</a>
    <li class="calls-super" ><a href="#method-i-delete">#delete</a>
    <li ><a href="#method-i-delete_if">#delete_if</a>
    <li ><a href="#method-i-each">#each</a>
    <li ><a href="#method-i-each_pair">#each_pair</a>
    <li class="calls-super" ><a href="#method-i-each_value">#each_value</a>
    <li class="calls-super" ><a href="#method-i-fetch">#fetch</a>
    <li ><a href="#method-i-has_value-3F">#has_value?</a>
    <li class="calls-super" ><a href="#method-i-index">#index</a>
    <li ><a href="#method-i-invert">#invert</a>
    <li ><a href="#method-i-key">#key</a>
    <li ><a href="#method-i-reject">#reject</a>
    <li ><a href="#method-i-replace">#replace</a>
    <li ><a href="#method-i-select">#select</a>
    <li class="calls-super" ><a href="#method-i-shift">#shift</a>
    <li class="calls-super" ><a href="#method-i-store">#store</a>
    <li ><a href="#method-i-to_a">#to_a</a>
    <li ><a href="#method-i-to_hash">#to_hash</a>
    <li ><a href="#method-i-update">#update</a>
    <li class="calls-super" ><a href="#method-i-values">#values</a>
    <li ><a href="#method-i-values_at">#values_at</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-YAML::DBM">
    <h1 id="class-YAML::DBM" class="class">
      class YAML::DBM
    </h1>

    <section class="description">
    
<p><a href="../YAML.html"><code>YAML</code></a> + <a href="DBM.html"><code>DBM</code></a> = YDBM</p>

<p><a href="DBM.html"><code>YAML::DBM</code></a> provides the same interface as ::DBM.</p>

<p>However, while <a href="DBM.html"><code>DBM</code></a> only allows strings for both keys and values, this library allows one to use most Ruby objects for values by first converting them to <a href="../YAML.html"><code>YAML</code></a>. Keys must be strings.</p>

<p>Conversion to and from <a href="../YAML.html"><code>YAML</code></a> is performed automatically.</p>

<p>See the documentation for ::DBM and <a href="../YAML.html"><code>::YAML</code></a> for more information.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-5B-5D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ydbm[key] &rarr; value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Return value associated with <code>key</code> from database.</p>

<p>Returns <code>nil</code> if there is no such <code>key</code>.</p>

<p>See <a href="DBM.html#method-i-fetch"><code>fetch</code></a> for more information.</p>

                              <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 29</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]</span>( <span class="ruby-identifier">key</span> )
    <span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">key</span> )
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-5B-5D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          ydbm[key] = value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Set <code>key</code> to <code>value</code> in database.</p>

<p><code>value</code> will be converted to <a href="../YAML.html"><code>YAML</code></a> before storage.</p>

<p>See <a href="DBM.html#method-i-store"><code>store</code></a> for more information.</p>

                              <div class="method-source-code" id="5B-5D-3D-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 41</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]=</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span> )
    <span class="ruby-identifier">store</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span> )
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-delete" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete(key)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Deletes value from database associated with <code>key</code>.</p>

<p>Returns value or <code>nil</code>.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="delete-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 102</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete</span>( <span class="ruby-identifier">key</span> )
    <span class="ruby-identifier">v</span> = <span class="ruby-keyword">super</span>( <span class="ruby-identifier">key</span> )
    <span class="ruby-keyword">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">v</span>
        <span class="ruby-identifier">v</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>( <span class="ruby-identifier">v</span> )
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-delete_if" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          delete_if { |key, value| ... }
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calls the given block once for each <code>key</code>, <code>value</code> pair in the database. Deletes all entries for which the block returns true.</p>

<p>Returns <code>self</code>.</p>

                              <div class="method-source-code" id="delete_if-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 117</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete_if</span> <span class="ruby-comment"># :yields: [key, value]</span>
    <span class="ruby-identifier">del_keys</span> = <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">dup</span>
    <span class="ruby-identifier">del_keys</span>.<span class="ruby-identifier">delete_if</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span>( <span class="ruby-identifier">k</span>, <span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">k</span> ) ) <span class="ruby-operator">==</span> <span class="ruby-keyword">false</span> }
    <span class="ruby-identifier">del_keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">delete</span>( <span class="ruby-identifier">k</span> ) }
    <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-each" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">each</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="DBM.html#method-i-each_pair">each_pair</a>
                            </div>
                          </div>

                  <div id="method-i-each_pair" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">each_pair</span><span
                                class="method-args"> { |key, value| } { |key, value| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calls the given block once for each <code>key</code>, <code>value</code> pair in the database.</p>

<p>Returns <code>self</code>.</p>

                              <div class="method-source-code" id="each_pair-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 140</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_pair</span> <span class="ruby-comment"># :yields: [key, value]</span>
    <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span> <span class="ruby-identifier">k</span>, <span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">k</span> ) }
    <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="DBM.html#method-i-each">each</a>
                            </div>

                          </div>

                  <div id="method-i-each_value" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          each_value { |value| ... }
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Calls the given block for each value in database.</p>

<p>Returns <code>self</code>.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="each_value-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 151</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each_value</span> <span class="ruby-comment"># :yields: value</span>
    <span class="ruby-keyword">super</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span> <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>( <span class="ruby-identifier">v</span> ) }
    <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fetch" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          fetch( key, ifnone = nil )
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          fetch( key ) { |key| ... }
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Return value associated with <code>key</code>.</p>

<p>If there is no value for <code>key</code> and no block is given, returns <code>ifnone</code>.</p>

<p>Otherwise, calls block passing in the given <code>key</code>.</p>

<p>See ::DBM#fetch for more information.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="fetch-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 56</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fetch</span>( <span class="ruby-identifier">keystr</span>, <span class="ruby-identifier">ifnone</span> = <span class="ruby-keyword">nil</span> )
    <span class="ruby-keyword">begin</span>
        <span class="ruby-identifier">val</span> = <span class="ruby-keyword">super</span>( <span class="ruby-identifier">keystr</span> )
        <span class="ruby-keyword">return</span> <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>( <span class="ruby-identifier">val</span> ) <span class="ruby-keyword">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">val</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">IndexError</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
        <span class="ruby-keyword">yield</span> <span class="ruby-identifier">keystr</span>
    <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">ifnone</span>
    <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-has_value-3F" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          has_value?(value)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if specified <code>value</code> is found in the database.</p>

                              <div class="method-source-code" id="has_value-3F-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 168</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">has_value?</span>( <span class="ruby-identifier">val</span> )
    <span class="ruby-identifier">each_value</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">val</span> }
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-index" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">index</span><span
                                class="method-args">( keystr )</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Deprecated, used <a href="DBM.html#method-i-key"><code>YAML::DBM#key</code></a> instead.</p>
<hr>

<p>Note: <a href="DBM.html#method-i-index"><code>YAML::DBM#index</code></a> makes warning from internal of ::DBM#index. It says ‘DBM#index is deprecated; use <a href="DBM.html#method-i-key"><code>DBM#key</code></a>’, but <a href="DBM.html#method-i-key"><code>DBM#key</code></a> behaves not same as <a href="DBM.html#method-i-index"><code>DBM#index</code></a>.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="index-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 76</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">index</span>( <span class="ruby-identifier">keystr</span> )
    <span class="ruby-keyword">super</span>( <span class="ruby-identifier">keystr</span>.<span class="ruby-identifier">to_yaml</span> )
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-invert" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          invert &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a Hash (not a <a href="DBM.html"><code>DBM</code></a> database) created by using each value in the database as a key, with the corresponding key as its value.</p>

<p>Note that all values in the hash will be Strings, but the keys will be actual objects.</p>

                              <div class="method-source-code" id="invert-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 181</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">invert</span>
    <span class="ruby-identifier">h</span> = {}
    <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">k</span> ) ] = <span class="ruby-identifier">k</span> }
    <span class="ruby-identifier">h</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-key" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          key(value) &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the key for the specified value.</p>

                              <div class="method-source-code" id="key-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 84</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">key</span>( <span class="ruby-identifier">keystr</span> )
    <span class="ruby-identifier">invert</span>[<span class="ruby-identifier">keystr</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-reject" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          reject { |key, value| ... }
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Converts the contents of the database to an in-memory Hash, then calls Hash#reject with the specified code block, returning a new Hash.</p>

                              <div class="method-source-code" id="reject-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 129</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">reject</span>
    <span class="ruby-identifier">hsh</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">to_hash</span>
    <span class="ruby-identifier">hsh</span>.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span> <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-replace" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          replace(hash) &rarr; ydbm
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Replaces the contents of the database with the contents of the specified object. Takes any object which implements the <a href="DBM.html#method-i-each_pair"><code>each_pair</code></a> method, including Hash and <a href="DBM.html"><code>DBM</code></a> objects.</p>

                              <div class="method-source-code" id="replace-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 193</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">replace</span>( <span class="ruby-identifier">hsh</span> )
    <span class="ruby-identifier">clear</span>
    <span class="ruby-identifier">update</span>( <span class="ruby-identifier">hsh</span> )
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-select" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          select { |key, value| ... }
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          select(*keys)
                              </span>
                            </div>

                            <div class="method-description">
                              <p>If a block is provided, returns a new array containing [key, value] pairs for which the block returns true.</p>

<p>Otherwise, same as <a href="DBM.html#method-i-values_at"><code>values_at</code></a></p>

                              <div class="method-source-code" id="select-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 219</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">select</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">keys</span> )
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> = <span class="ruby-keyword">self</span>[<span class="ruby-identifier">k</span>]; [<span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>] <span class="ruby-keyword">if</span> <span class="ruby-keyword">yield</span> <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span> }.<span class="ruby-identifier">compact</span>
    <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">values_at</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">keys</span> )
    <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-shift" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          shift &rarr; [key, value]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Removes a [key, value] pair from the database, and returns it. If the database is empty, returns <code>nil</code>.</p>

<p>The order in which values are removed/returned is not guaranteed.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="shift-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 205</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">shift</span>
    <span class="ruby-identifier">a</span> = <span class="ruby-keyword">super</span>
    <span class="ruby-identifier">a</span>[<span class="ruby-value">1</span>] = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>( <span class="ruby-identifier">a</span>[<span class="ruby-value">1</span>] ) <span class="ruby-keyword">if</span> <span class="ruby-identifier">a</span>
    <span class="ruby-identifier">a</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-store" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          store(key, value) &rarr; value
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Stores <code>value</code> in database with <code>key</code> as the index. <code>value</code> is converted to <a href="../YAML.html"><code>YAML</code></a> before being stored.</p>

<p>Returns <code>value</code></p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="store-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 234</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">store</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span> )
    <span class="ruby-keyword">super</span>( <span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_yaml</span> )
    <span class="ruby-identifier">val</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_a" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_a &rarr; array
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Converts the contents of the database to an array of [key, value] arrays, and returns it.</p>

                              <div class="method-source-code" id="to_a-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 259</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_a</span>
    <span class="ruby-identifier">a</span> = []
    <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">push</span> [ <span class="ruby-identifier">k</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">k</span> ) ] }
    <span class="ruby-identifier">a</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_hash" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_hash &rarr; hash
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Converts the contents of the database to an in-memory Hash object, and returns it.</p>

                              <div class="method-source-code" id="to_hash-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 271</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_hash</span>
    <span class="ruby-identifier">h</span> = {}
    <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[ <span class="ruby-identifier">k</span> ] = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">k</span> ) }
    <span class="ruby-identifier">h</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-update" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          update(hash) &rarr; ydbm
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Updates the database with multiple values from the specified object. Takes any object which implements the <a href="DBM.html#method-i-each_pair"><code>each_pair</code></a> method, including Hash and <a href="DBM.html"><code>DBM</code></a> objects.</p>

<p>Returns <code>self</code>.</p>

                              <div class="method-source-code" id="update-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 247</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update</span>( <span class="ruby-identifier">hsh</span> )
    <span class="ruby-identifier">hsh</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">self</span>.<span class="ruby-identifier">store</span>( <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span> )
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-values" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          values
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array of values from the database.</p>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="values-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 160</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">values</span>
    <span class="ruby-keyword">super</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>( <span class="ruby-identifier">v</span> ) }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-values_at" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          values_at(*keys)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an array containing the values associated with the given keys.</p>

                              <div class="method-source-code" id="values_at-source">
            <pre><span class="ruby-comment"># File yaml/dbm.rb, line 92</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">values_at</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">keys</span> )
    <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">fetch</span>( <span class="ruby-identifier">k</span> ) }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

